import { AxiosResponse, AxiosRequestConfig } from "axios";
const PRODUCT = process.env.NODE_ENV == "production";
let headers = {
    "Content-Type": "application/json",
    "X-Requested-With": "XMLHttpRequest"
};

if (process.env.NODE_ENV == "development") {
    //开发环境,请求头设置参数
    headers = Object.assign({}, headers, {
        wecSchoolId: 1019427682571829,
        wecUserInfo: JSON.stringify({
            userAccount: "123123",
            userName: "admin1",
            userId: "72786"
        })
    });
}

const axiosConfig: AxiosRequestConfig = {
    baseURL: PRODUCT ? "/wec-smmp-bd" : "/wec-smmp-bd",
    // baseURL: PRODUCT ? "/wec-smmp-home" : "/wec-smmp-home", 用户信息的接口
    headers: headers,
    // 请求后的数据处理
    transformResponse: [
        function(data: AxiosResponse) {
            return data;
        }
    ],
    transformRequest: [
        function(data = {}) {
            return JSON.stringify(data);
        }
    ],
    // 超时设置s
    timeout: 30000,
    // 跨域是否带Token
    withCredentials: false,
    responseType: "json",
    // xsrf 设置
    xsrfCookieName: "XSRF-TOKEN",
    xsrfHeaderName: "X-XSRF-TOKEN",
    // 最多转发数，用于node.js
    maxRedirects: 5,
    // 最大响应数据大小
    maxContentLength: 2000
};
export default axiosConfig;
